﻿using System;
using UnityEngine;

public static class ExtendStr
{
    public static Color GetColor(this string str)
    {
        var rgbstr = str.Split('{', ',', ',', '}');
        return new Color(float.Parse(rgbstr[1])/255, float.Parse(rgbstr[2])/255, float.Parse(rgbstr[3])/255);
    }
}
/// <summary>
/// 文本类
/// </summary>
public class TextContent
{
    public string content;
    public Color color;
    public int typeSpeed;
    public bool lineBreak;
    private int m_size;//不要超过96
    public int size { get =>  m_size > 96||m_size<=0 ? m_size = 96: m_size; set => m_size = value; }
    public float width = 0;
    public Command command=null;

    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="content"></param>
    /// <param name="size">大小不要超过30</param>
    /// <param name="color"></param>
    /// <param name="typeSpeed">打字间隔（ms）</param>
    /// <param name="lineBreak">是否换行</param>
    public TextContent(string content = "", int size = 0, bool lineBreak = false, int typeSpeed = 100)
    {
        this.content = content;
        this.size = size;
        this.color = Color.black;
        this.typeSpeed = typeSpeed;
        this.lineBreak = lineBreak;
    }
    public TextContent(string content, int size, Color color, bool lineBreak = false, int typeSpeed = 100)
    {
        this.content = content;
        this.size = size;
        this.color = color;
        this.typeSpeed = typeSpeed;
        this.lineBreak = lineBreak;
    }

}
